import { Navigate, useRoutes } from 'react-router-dom'
import { RouteObject } from '@/router/interface'
import Login from '@/ui/antd/pages/login/Login'
import NotFound from '@/ui/antd/pages/404/404'
import main from '@/router/routes/main'
import demo from '@/router/routes/demo'

// * 处理路由
export const routeArray: RouteObject[] = [...main, ...demo]

export const rootRoutes: RouteObject[] = [
	{
		path: '/',
		element: <Navigate to="/login" />,
	},
	{
		path: '/login',
		element: <Login />,
		meta: {
			requiresAuth: false,
			title: '登录页',
			key: 'login',
		},
	},
	...routeArray,
	{
		path: '/404',
		element: <NotFound />,
	},
	{
		path: '*',
		element: <Navigate to="/404" />,
	},
]
console.log('所有路由', rootRoutes)
const Router = () => {
	const routes = useRoutes(rootRoutes)
	return routes
}

export default Router
